<template>
  <div>
    <top-header></top-header>
    <div class="add-prevue">
      <h2>添加预告</h2>
      <div class="prevue-title">
        <h3>预告标题</h3>
        <input type="text" v-model="inputVal" />
        <h3>预告封面</h3>
        <el-upload
          class="upload-demo"
          action="https://jsonplaceholder.typicode.com/posts/"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :file-list="fileList"
          list-type="picture"
        >
          <el-button size="small" type="primary">选择文件</el-button>
          <div slot="tip" class="el-upload__tip">
            只能上传jpg/png文件，且不超过500kb
          </div>
        </el-upload>
        <!-- <el-upload
          action="https://jsonplaceholder.typicode.com/posts/"
          list-type="picture-card"
          :on-preview="handlePictureCardPreview"
          :on-remove="handleRemove"
        >
          <i class="el-icon-plus"></i>
        </el-upload>
        <el-dialog :visible.sync="dialogVisible">
          <img width="100%" :src="dialogImageUrl" alt="" />
        </el-dialog> -->
      </div>
      <div class="submit">
        <button @click="changeAdd">提交</button>
      </div>
    </div>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';
import TopHeader from "@/components/TopHeader.vue";
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {
    "top-header": TopHeader,
  },
  data() {
    //这里存放数据
    return {
      fileList: [
        {
          name: "food.jpeg",
          url:
            "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100",
        },
        {
          name: "food2.jpeg",
          url:
            "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100",
        },
      ],
      inputVal: "",
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    changeAdd() {
      this.$axios.post("/yugaoList", {
        biaoti: "",
        tupiurl: "",
      });
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang='scss' scoped>
.add-prevue {
  position: relative;
  width: 1220px;
  min-height: 500px;
  margin: 10px;
  background-color: white;
  border-top: 5px solid blue;
  h2 {
    padding-left: 10px;
    font-size: 18px;
    height: 50px;
    line-height: 50px;
    border-bottom: 1px solid rgb(228, 228, 228);
  }
  .prevue-title {
    h3 {
      height: 50px;
      line-height: 50px;
      font-weight: bold;
    }
    padding-left: 10px;
    input {
      width: 1190px;
      height: 30px;
    }
  }

  el-upload.upload-demo {
    el-button {
    }

    .el-upload__tip {
    }
  }
  .submit {
    width: 100%;
    border-top: 1px solid rgb(228, 228, 228);
    height: 50px;
    position: absolute;
    bottom: 0;
    button {
      position: absolute;
      left: 10px;
      top: 10px;
      width: 80px;
      height: 30px;
      background-color: #409eff;
      border: 0;
      color: white;
    }
  }
}
</style>